package com.naizhuai.ui.task.multtype;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.naizhuai.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import me.drakeet.multitype.ItemViewBinder;

/**
 * @author：lichenxi
 * @date 2018/5/5 18
 * email：525603977@qq.com
 * Fighting
 */
public class ImageBinderViewBinder extends ItemViewBinder<String, ImageBinderViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_image_binder, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull String imageBinder) {
        Glide.with(holder.itemView.getContext()).load(imageBinder).into(holder.imgBackgroud);
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.img_backgroud)
        ImageView imgBackgroud;
        ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
